SetCombatOverrides
/////////////////////////////////////////////////////////////////////////////// // SetCombatOverrides / ClearCombatOverrides /////////////////////////////////////////////////////////////////////////////// // Created By: Brock Heinz - OEI // Created On: 02/02/06 // Description: This is a basic way to force a specific outcome during a // creature's combat round. This is primarily designed as a // cutscene aid, and is not intended for use on creatures // with whom the player can normally interact. Therefore, these // settings are not saved. // ClearCombatOverrides() should be called on the creature when // the cutscene is complete. // Arguments: // oCreature - The creature to set the overrides on. // oTarget - This should be a creature, door, or placeable. // Passing in INVALID_OBJECT Will allow normal target selection to occur. // nAttackResult - An attack can have one of many different outcomes. // You can force the attack results to be a specific outcome, or specify // "INVALID" to allow the normal attack rolls to occur. // nOnHandAttacks, nOffHandAttacks // Creaturs must have a total of 1-6 attacks per round. Entering -1 for either of // these means that the default logic will be used to determine attacks per // round for that hand. // nMinDamage, nMaxDamage // These are used to set the range for a random damage amount. For example, // (1,6) would mean that 1-6 points of damage would be done. These can be set // to the same value, and you can specify 0,0 for "no damage". Using -1 for // either of these means that the default damage calculations will be used. // bSuppressBroadcastAOO - If TRUE then this creature can potentially cause an // attack of opportunity from nearby creatures. If FALSE, this will be supressed // bSuppressMakeAOO - If TRUE then this creature will make attacks of // opportunity when they are available. If FALSE, this will be supressed // bIgnoreTargetReaction - Normally, ActionAttack() calls are rejected if they // are made on a hostile or neutral target. Setting this to TRUE // will bypass that check. // bSuppressFeedbackText - If set to TRUE, this can be used to keep this // creature's combat round feedback from being displayed. /////////////////////////////////////////////////////////////////////////////// void SetCombatOverrides( object oCreature, object oTarget, int nOnHandAttacks, int nOffHandAttacks, int nAttackResult, int nMinDamage, int nMaxDamage, int bSuppressBroadcastAOO, int bSuppressMakeAOO, int bIgnoreTargetReaction, int bSuppressFeedbackText ); This is quite possibly one of the most useful functions in the toolset and simultaneously one of the most poorly described. Not only can most of its functionality be used outside of cutscenes, it is also one of the very few, if not the only, function that allows the scripter to directly influence the NWN2's combat engine. To begin, if oTarget is set to OBJECT_INVALID and not INVALID_OBJECT oTarget will default to the current target of oCreature. To clarify, if oCreature is the PC and oTarget is OBJECT_INVALID oTarget will become the monster that oPC has an action queued against. This becomes an important distinction in relation to the other parameters. For instance, setting both oTarget and oCreature to the PC can cause the PC to make attacks on itself. In the description it lists the parameter nAttackResult just after oTarget. This is erroneous, the order is correct in the function's parameter listing (nAttackResult follows nOffhandAttacks). The description also suggests to use "INVALID" to enable default attack rolls. This is somewhat obtuse. The constant for the default value does happen to be zero. nAttackResult uses the constants: OVERRIDE_ATTACK_RESULT_DEFAULT, OVERRIDE_ATTACK_RESULT_HIT_SUCCESSFUL, OVERRIDE_ATTACK_RESULT_PARRIED, OVERRIDE_ATTACK_RESULT_CRITICAL_HIT, and OVERRIDE_ATTACK_RESULT_MISS, for their respective results. So, for example, setting this parameter to OVERRIDE_ATTACK_RESULT_DEFAULT will enable normal attack rolls while setting it to OVERRIDE_ATTACK_RESULT_CRITICAL_HIT will guarantee that oCreature makes critical hits against oTarget. nAttackResult will apply to all attacks made while SetCombatOverrides is active on oCreature, so be careful if you use it in conjunction with nOnHandAttacks and nOffHandAttacks. nMinDamage and nMaxDamage apply only to physical damage. If oCreature Has an elemental damage increase ability on it, such as that granted by EffectDamageIncrease, that damage is applied separately no matter what these parameters are set to. It does not appear as if the physical damage type constants (DAMAGE_TYPE_BLUDGEONING, DAMAGE_TYPE_PIERCING, and DAMAGE_TYPE_SLASHING) change the result of nMinDamage and nMaxDamage. After extensive testing, this author has determined that bSuppressMakeAOO only prevents oCreature from making attacks of opportunity while both this parameter and the oCreature's Plot Flag are set to TRUE. SetPlotFlag will toggle this flag on and off. Keep in mind, before you decide to use this parameter, that the plot flag also makes its target invulnerable to damage. bSuppressFeedbackText suppresses the combat information of oTarget specifically. It prevents most combat actions from displaying such as attacks of opportunity or skill rolls. The interesting part about this parameter is that oCreature cannot place this parameter's override on itself without setting itself as the target of its own attacks. Furthermore, using AssignCommand on another creature (for the sake of argument, let's assume your character) with this function will allow it to suppress your combat information in your message window. It is fair to assume that, when active, oTarget's combat information is suppressed, it is suppressed globally, rather than only to oCreature. To clear the parameter you would need to call ClearCombatOverrides on oCreature (oCreature being the caller of the function). }} }}